package com.wang.jmonkey.modules.log.config;

import com.wang.jmonkey.common.constant.RabbitConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 消息队列配置
 * @Author HeJiawang
 * @Date 2021/5/21 15:34
 */
@Configuration
public class RabbitConfig {

    @Bean
    public TopicExchange logExchange() {
        return new TopicExchange(RabbitConstant.EXCHANGE_LOG, true , false);
    }

    @Bean
    public Queue logHandleQueue() {
        return new Queue(RabbitConstant.QUEUE_LOG_HANDLE,true);
    }

    @Bean
    Binding startStopBinding() {
        return BindingBuilder.bind(logHandleQueue()).to(logExchange()).with(RabbitConstant.QUEUE_LOG_HANDLE);
    }

}
